package com.wen.oop07;

public class student extends person{
public void go(){
    System.out.println("gogogo");
}
}



/*package com.wen;

import com.wen.oop07.person;
import com.wen.oop07.student;
import com.wen.oop07.teacher;

public class application {

    public static void main(String[] args) {
//        System.out.println(x instanceof y);,取决于x是否与y有继承关系，且类x是实例x的引用类型
        //    外祖父类
//        Object > String
//        Object > person > student
//        Object > person > teacher
//        旁系的都是false，直系的都是true
     Object s1=new student();
        System.out.println(s1 instanceof person);//true
        System.out.println(s1 instanceof student);//true
        System.out.println(s1 instanceof Object);//true
        System.out.println(s1 instanceof teacher);//false
        System.out.println(s1 instanceof String);//false
        System.out.println("=============================================");
        person s2 = new person();
        System.out.println(s2 instanceof person);//true
        System.out.println(s2 instanceof student);//false
        System.out.println(s2 instanceof Object);//true
        System.out.println(s2 instanceof teacher);//false
//        System.out.println(s2 instanceof String);//false编译就报错，
        System.out.println("=============================================");

        student s3=new student();
        System.out.println(s3 instanceof person);//true
        System.out.println(s3 instanceof student);//true
        System.out.println(s3 instanceof Object);//true
//        System.out.println(s3 instanceof teacher);//false完全没关系就会在编译阶段报错
//        System.out.println(s3 instanceof String);//false
        System.out.println("=============================================");
    }
}

*/

/*package com.wen;

import com.wen.oop07.person;
import com.wen.oop07.student;
import com.wen.oop07.teacher;

public class application {

    public static void main(String[] args) {
//类型之间的转换，基本类型转换高低64-32
//       父  子
//       person student = new person();
       person obj = new student();
        //由高转低  将这个对象转换为student类型，就可以使用studen类型的方法了,
        student obj1 = (student) obj;
        ((student) obj).go();
//由低转高,子类转父类可能会丢失一些自己的东西
        student student = new student();
student.go();
person person=student;

    }
}
/*父类引用指向子类对象，把子类转换为父类，向上转型
* 父类转子类向下转型，强制转换，可能会丢失方法
* 方便方法调用，减少代码，简洁*/

